package com.kfh.ybracelet.utils;

import android.content.Context;
import android.content.Intent;

import com.kfh.ybracelet.bean.TopicBean;
import com.kfh.ybracelet.login.LoginActivity;

import java.util.Map;

/**
 * 常量类
 * Created by Administrator on 2015/7/14.
 */
public class Constant {

    public final static String HOST = "https://kungfuhacking.cn";
    //        public final static String HOST_IP = "http://10.0.0.5:10008";//本地
//    public final static String HOST_IP = "http://115.29.197.110:10006";//测试环境
    public final static String HOST_IP = HOST + ":19991";//正式

    public final static String HOST_IP_TEST = HOST + ":19992";//支付端口
    //    public final static String HOST_IP = "https://www.kungfuhacking.com:19991";//正式
//    public final static String HOST_IP = "http://121.40.98.39:19991";//正式
//    public final static String HOST_IP = HOST + ":19992";//测试
//    public final static String HOST = "https://test.healxh.cn";
//    public final static String HOST = "https://healxh.cn";

    //    public final static String WEB_ROOT = "https://www.kungfuhacking.com:19991/family/";
    public final static String WEB_ROOT = HOST_IP + "/yellow/";
    public final static String WEB_ROOT_PAY = HOST_IP_TEST + "/yellow/";//支url

    public final static String WEB_ROOT_TALK = HOST_IP + "/talk/";

    public final static String INREQUIRE = HOST + "/questionnaire/";//问卷调查
    public final static String DONATE = HOST + "/donation/";//捐赠
    public final static String PAYSIM = HOST + "/paysim/";//充值
    public final static String QA = HOST + "/QA/";//QA 客服中心

    public final static String CONFIG = "ybracelet_config";
// 17600859617  222222 见见   18310861283 111111 小丽

    //    测试消息详情webview加载的url    18610915892  111111


    ///////////// 微信APPID //////////////
    public final static String APP_ID_WEIXIN = "wx6a271c2c414a2f13";//

    //    public static final String ISFIRST = "isFirst";//是否是第一次打开app
    public final static String LOGIN = "login";//登录
    public final static String TALK_LOGIN = "talkLogin";//登录
    //    public final static String TALK_LOGIN = "login";//登录
    public final static String REGISTER = "regCheck";//注册 提交验证 验证码
    public final static String FORGETCHECK = "forgetCheck";//忘记密码 提交验证 验证码
    public final static String REG = "reg";   //注册
    public final static String FORGET = "forget";  //忘记密码
    public final static String SMSCODE = "smsCode";//注册
    //    public final static String GETTREE = "getTree"; //获取宝宝树列表
//    public final static String GETCHILDERN = "getChildern";//发宝宝树时 选择宝宝
//    public final static String SENDTREE = "sendTree"; //发布宝宝树
//    public final static String DELTREE = "delTree";//删除宝宝树
    public final static String GETCHILDERNANDEWATCH = "getChildernAndWatch";//获取关注孩子的信息
    public final static String UPDATEUSERINFO = "updateUserInfo";//更改用户信息
    public final static String UPDATECHILDINFO = "updateChildInfo"; //更改宝宝详情
    public final static String ADDWATCH = "addWatch"; //SN码
    public final static String CHECKINVITEKEY = "checkInviteKey"; //家长通过邀请码绑定孩子
    public final static String CREATECHILD = "createChild";//创建宝宝空间
    public final static String UPLOADTOKEN = "uploadToken"; // 上传七牛图片
    public final static String GETCHILDERNANDWATCH = "getChildernAndWatch";  //手表状态
    public final static String VERSION = "ver"; //获取版本信息
    //    public final static String SEARCHMSG = "searchMsg"; //搜索消息
    public final static String GETCHILDINFO = "getChildInfo";
    public final static String MYLIST = "getChildrenInfo";
    //    public final static String SENDCOMMENT = "sendComment";//宝宝树发表评论
    public final static String GETINVITEKEY = "getInviteKey";//获取孩子的邀请码
    public final static String GETAREALIST = "getAreaList"; //安全区域列表
    public final static String ADDAREA = "addArea";//添加安全区域
    public final static String DELAREA = "delArea"; //删除安全区域
    //    public final static String CHILDBINDCLASS = "childBindClass";//二维码接口
    public final static String GETCHILDLOCLIST = "getChildLocList"; //获取孩子的历史定位信息
    public final static String GETWHITELIST = "getWhiteList"; //获取手表白名单
    public final static String UPDATEWHITELIST = "updateWhiteList";  //更新白名单
    public final static String DELCHILD = "delChild"; //删除孩子
    public final static String UNBINDWTACH = "delWatch"; //解绑定孩子
    //    public final static String UNBINDWATCH = "delWatch"; //解绑手表
    //    public final static String uploadPic = "uploadPic";//上传图片
    public final static String GETCHILDLOC = "getChildLoc"; //获取孩子的位置
    public final static String UPDATELEVEL = "updateLevel";//调整权限
    //    public final static String SOSTELL = "setWatchSOS"; //双向通话
    public final static String FINDWATCH = "findWatch"; //查找手表
    //    public final static String MESSAGECOUNT = "msgInfoNum";//未读消息个数, 显示的小红点
    public final static String SETWATCHPHONE = "setWatchPhoneNum"; //设置手表电话
    public final static String CHILDINFO = "getChildFamilyInfo"; //获取孩子家庭详情
    public final static String UPDATEFAMILYINFO = "updateChildFamilyInfo";//更新家庭信息
    //    public final static String GETRECEIVEMSGLIST = "getReceiveMsgList"; //获得收件箱列表
    public final static String MODUFYCODE = "updatePwd"; //修改密码
//    public final static String UPLOADTOKEN = "uploadToken"; //上传图片

    public final static String SEARCHUSER = "searchUser"; //搜索用户
    public final static String INVITEFRIEND = "inviteFriend"; //发送好友申请
    public final static String MYCONTACTS = "myContacts"; //通讯录
    public final static String INVITEDLIST = "invitedList"; //邀请列表
    public final static String DEALINVITE = "dealInvite"; //处理好友请求
    public final static String JOINGROUP = "joinGroup"; //创建群组
    //    public final static String UPLOADGROUPPIC = "UploadGroupPic"; //上传群头像
    public final static String LEFTGROUP = "leftGroup"; //退出群聊
    public final static String GROUPLIST = "groupList"; //群聊列表
    public final static String CHILDTALKLIST = "childTalkList"; //家庭群列表
    public final static String GROUPINFO = "groupInfo"; //群信息
    public final static String GROUPSETTING = "groupSetting"; //群设置
    //    public final static String USERHISTORY = "userHistory"; //离线消息
    public final static String DELFRIEND = "delFriend"; //删除好友
    public final static String UPDATEGROUPADMIN = "updateGroupAdmin"; //修改群主
    public final static String IDENTITY = "identity"; //实名认证
    public final static String BINDYELLOW = "bindYellow"; //扫描二维码后绑定手表
    public final static String PAY = "pay"; //支付
    public final static String PRODUCTLIST = "productList"; //获取支付套餐列表
    public final static String CHECKPHONENUM = "checkPhoneNum"; //查询手机号实名认证状态
    public final static String PAYHISTORY = "payHistory"; //订单列表
    public final static String PHONENUMINFO = "phoneNumInfo"; //订单详情
    public final static String CHECKEXPRESS = "checkExpress"; //订单物流信息


    public final static String MQTTIP = "MQTTIP"; //mqtt登录ip
    public final static String MQTTPORT = "MQTTPORT"; //mqtt登录端口

    //上传图片
//    public final static String UPLOADPIC = "uploadPic";
//    public final static String MESSAGES = "getReceiveMsgList";
//    public final static String BABYDETAILS = "xxxxx";

    public final static String FREMAL = "女"; //性别
    public final static String PHOTO_PATH = "/YbraceletCache";
    public final static String PHOTO_PATH_HINT = "/.YbraceletCache";
    //    public final static String BUILD = "build";  //版本配置文件
//    public final static String VERDATA = "ver_data"; //存储配置文件信息的key
//    public final static String ADDBITMAPPATH = "mlx/add.jpg";  //添加的图片 + 的地址 (乱写的地址)
    public final static String MINGLUXING_CODE = "我是明路星家长端的密码";// 电量消息

    public final static String NODATA = "数据获取失败";
    //    public final static String NOMOREDATA = "没有更多数据了";
    //    public final static String LOADING = "加载中...";
    public final static String WAIT = "请稍后...";
    //    public final static String MODIFY = "修改中...";
    public static final String NEWS = "NEWS";
    public static final String CHILD = "CHILD";
    //    public static final String PHOTO = "PHOTO";
    public static final String BABYTREE = "BABYTREE";
    public static final String MY = "MY";

    public static final int STATUS_SUCCESS = 0;// 成功
    //    public static final int SUCCESES =1008;// 成功
    private static final int FA_UNKNOW_ERROR = 1000;// 未知错误
    private static final int FA_PHONENUM_EXIST = 1001;// 电话号码已存在/注册时
    private static final int FA_MSCODE_ERROR = 1004;// 短信验证码错误
    private static final int FA_MSCODESEND_ERROR = 1005;// 短信验证码发送失败
    private static final int FA_PHONENUM_NOT_EXIST = 1002;// 电话号码不存在
    private static final int FA_AES_ERROR = 113;// 解密失败
    private static final int FA_PHONENUM_ERROR = 114;// 电话号码错误/登陆时
    private static final int FA_PASSWORD_ERROR = 1003;// 密码错误
    public static final int FA_PHNOEKEY_ERROR = 1006;// phonekey与上次登陆时不一致//TOKEN错误
    public static final int FA_TOKEN_TIMEOUT_ERROR = 1007;// TOKEN超时
    private static final int FA_VERSION_OLD = 1008;//版本落后
    private static final int FA_SN_ERROR = 1009;//SN不存在
    private static final int FA_SN_BIND_ERROR = 1010;//SN已经被绑定
    private static final int FA_BIND_ERROR_INVITATION = 1018;// 邀请码错误
    private static final int FA_BIND_ERROR = 117;// SN码错误
    private static final int FA_DEVICEID_ERROR = 201;// 设备ID错误
    private static final int FA_NO_DATA_ERROR = 203;// 数据库中无记录
    private static final int FA_DEVICECONNECT_ERROR = 204;// 设备无连接
    private static final int FA_BINDING_ALREADY = 205;// 绑定错误
    private static final int FA_DATA_FORMATE_ERROR = 3000;// 数据格式错误
    private static final int FA_DATA_ERROR = 3001;// 数据错误
    public static final int FA_RIGHT_ERROR = 9999;// 无权限
    private static final int FA_API_ERROR = 404;// 接口不存在
    //    private static final int POWER_ERROR = 1019;// 权限错误
    private static final int UNBIND_DELETE_ERROR = 1020;// 解绑孩子仍然绑定手表,请先解绑孩子的手表后,在解绑定孩子
    private static final int UNBIND_ONLY_ONE_ERROR = 1019;// 解绑定人为唯一管理员,请提升另一人为管理员后再解绑定
//    private static final int ADD_FRIEND_SUCCESS = 4001;//

    //{"code":1020,"code_msg":""}
    public static final String TOKEN = "TOKEN";//
    public static final String USERIMG = "USERIMG";//
    //    public static final String IMAGEURL = "imageUrl";//
    public static final String NICKNAME = "NICKNAME";//
    public static final String AGE = "AGE";//
    public static final String PSW = "PSW";//
    public static final String SEX = "SEX";//
    public static final String BIRTHDAY = "BIRTHDAY";//
    public static final String BABYBIRTHDAY = "BABYBIRTHDAY";//
    public static final String MOBILE = "MOBILE";//
    public static final String id = "id";
    public static final String NAME = "NAME";//
    //    public final static String USERNAME = "USERNAME";
    public final static String USERID = "USERID";
    public final static String INVITEKEY = "INVITEKEY";
    public final static String CURRENTCHILDID = "CURRENTCHILDID";
    public final static String CURRENTCHILDNAME = "CURRENTCHILDNAME";
    public final static String LEVEL = "LEVEL";

    public final static String MQTTNOTCONNECT = "MQTTNOTCONNECT";//mqtt未连接

//    public final static String MSG_MESSAGE = "1001001"; //消息
    //    public final static String MSG_UNFINISHED_WORK = "1001002"; //代办事项
//    public final static String MSG_NOTIFICATION = "1001003";//通知

//    //系统topic
//    public static String SYSTEM_TOPIC = "";

    public static String[] TOPICS;//

    public static Map<String, TopicBean> topicMap;//

    public static String currentContractTopic = "";//当前聊天的id

    //////////////////////       信息发送类型     ////////////////////
    public static final String MQTTMESSAGETEXT = "Text";//文本
    public static final String MQTTMESSAGEPHOTO = "Picture";//图片
    public static final String MQTTMESSAGEVOICE = "Voice";//语音
    public static final String MQTTMESSAGETODO = "Todo";//网页代办
    public static final String MQTTMESSAGENOTICE = "Notice";//通知, 创建群, 删人 加人

    public static final int EMO_PAGE_ONE = 0;
    public static final int EMO_PAGE_TWO = 1;
    public static final int EMO_PAGE_THREE = 2;

    public static final String DELETEEMO = "[delete]";

    //聊天记录表
    public static final String HISTORY_TABLE = "chatHistory";
    //订阅的主题表  和 聊天的最新的一条记录表
    public static final String TOPIC_TABLE = "topics";
    //数据库名称
    public static final String DB_NAME = "ckmqtt.db";

    public static final String SUB = "sub";
    public static final String UN_SUB = "unsub";

    //上传失败的默认头像
    public static final String IMAGE_URL_FAIL = "http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-29/tx1yb3c7n4m9xzbp9hfa93df5w7us9y43tivgwlthnhbfxrn8aysijrol8uj3s5m_s";

    public static final String START_SINGLE = "/f/";//单聊
    public static final String START_GROUP = "/g/";//群聊
    public static final String START_CHILD = "/c/";//家庭圈 // 圈子
    public static final String START_S = "/s/";//系统 显示
    public static final String START_SYSTEM = "/system/";//系统 (不显示) sub unsub

//    public static final String SYSTEM = "/system/";//系统消息
//    public static final String SYSTEM_1 = "/system/1/";//

    public static final int CHAT_HISTORY_COUNT = 20;//聊天历史查询的个数

    /**
     * messagebean 字段中 operationStyle 的类型
     */
    public static final String DELETE_RECENT_HISTORY = "DELETE_RECENT_HISTORY";//删除最近聊天记录code
    public static final String OFF_GROUP = "OFF_GROUP";//退出群,删除人的code
    public static final String RECEIVE_MESSAGE = "RECEIVE_MESSAGE";//接受到新消息

    public static final String TOPIC_MAP = "TOPIC_MAP";//保存到sp中的 topicName 和 topicPic
    public static final String UPDATE_RED_COUNT = "UPDATE_RED_COUNT";//通知底部状态栏更新小红点个数


    /**
     * 新消息是否提醒 1 不提醒, 默认提醒 (默认为0)
     */
    public static final String REMAIND = "REMAIND";//1
//    public static final String REMAIND_TRUE = "1";//1
//    public static final String REMAIND_FALSE = "0";//

    public static final int CREATE_GROUP = 0x121;//创建群聊
    public static final int DELETE_GROUP_NUMS = 0x122;//删除群成员
    public static final int ADD_GROUP_NUMS = 0x123;//添加群成员

    public static final int MQTT_QOS_ONCE = 1;//mqtt qos
    public static final int MQTT_QOS_SUB = 1;//mqtt qos

    public static final int UNLISTENER = 0;//语音未读取状态
    public static final int LISTENERED = 1;//语音读取过的状态

//    public static final int NOTIFY_MESSAGE_COME = 0x99;//新消息到达的提示


    ////微信支付
    public static final String PAY_STYLE_WEIXIN = "weiApp";
    ////支付宝支付
    public static final String PAY_STYLE_ALIPAY = "aliApp";



    /**
     * 发送警告类型
     */
    public static final int MESSAGE = 700;// 普通消息
    public static final int BIND_MESSAGE = 701;// 绑定消息
    public static final int SAFEAREA_MESSAGE = 702;// 安全围栏消息
    public static final int BATTERY_MESSAGE = 703;// 电量消息

    public final static int SUCCESS = 1000;
    public final static int E_NOSDCARD = 1001;
    public final static int E_STATE_RECODING = 1002;
    public final static int E_UNKOWN = 1003;

//    public static String getErrorInfo(Context vContext, int vType) {
//        switch (vType) {
//            case SUCCESS:
//                return "success";
//            case E_NOSDCARD:
//                return vContext.getResources().getString(R.string.error_no_sdcard);
//            case E_STATE_RECODING:
//                return vContext.getResources().getString(R.string.error_state_record);
//            case E_UNKOWN:
//            default:
//                return vContext.getResources().getString(R.string.error_unknown);
//
//        }
//    }


//    //获得发件箱列表
//    public final static String GETMSGLIST = "getSendMsgList";

    public static String showErrorMsg(int code, Context ctx) {

        String errorMessage = "";

        switch (code) {

//            case FA_UNKNOW_ERROR:
//                errorMessage = "未知错误";
//                break;
            case FA_PHONENUM_EXIST:
                errorMessage = "电话号码已存在";
                break;
            case FA_MSCODE_ERROR:
                errorMessage = "短信验证码错误";
                break;
            case FA_MSCODESEND_ERROR:
                errorMessage = "短信验证码发送失败";
                break;
            case FA_AES_ERROR:
                errorMessage = "解密失败";
                break;
            case FA_PHONENUM_ERROR:
                errorMessage = "电话号码错误";
                break;
            case FA_PASSWORD_ERROR:
                errorMessage = "密码错误";
                break;
            case FA_PHNOEKEY_ERROR:
            case FA_TOKEN_TIMEOUT_ERROR:
                errorMessage = "登录超时";

//                MyApplication myApplication = (MyApplication) ctx.getApplicationContext();
//                myApplication.clearActivity();

                Intent intent = new Intent(ctx, LoginActivity.class);
                intent.putExtra("isAutoLogin", false);
//                intent.putExtra("isExit", true);
//                intent.addFlags(Intent.);
                ctx.startActivity(intent);

                break;
            case FA_DEVICEID_ERROR:
                errorMessage = "设备ID错误";
                break;

            case FA_DATA_ERROR:
                errorMessage = "数据错误";
                break;
            case FA_PHONENUM_NOT_EXIST:
                errorMessage = "电话号码不存在";
                break;
            case FA_DEVICECONNECT_ERROR:
                errorMessage = "设备无连接";
                break;
            case UNBIND_ONLY_ONE_ERROR:
                errorMessage = "解绑定人为唯一管理员,请提升另一人为管理员后再解绑定";
                break;

            case FA_BIND_ERROR:
                errorMessage = "SN码错误";
                break;
            case FA_BIND_ERROR_INVITATION:
                errorMessage = "邀请码错误";
                break;
            case FA_BINDING_ALREADY:
                errorMessage = "已经绑定";
                break;
            case MESSAGE:
                errorMessage = "普通消息";
                break;
            case BIND_MESSAGE:
                errorMessage = "绑定消息";
                break;
            case FA_DATA_FORMATE_ERROR:
                errorMessage = "数据格式错误";
                break;
            case SAFEAREA_MESSAGE:
                errorMessage = "安全围栏消息";
                break;

            case BATTERY_MESSAGE:
                errorMessage = "电量消息";
                break;

            case FA_UNKNOW_ERROR:
                errorMessage = "未知错误";
                break;

            case FA_VERSION_OLD:
                errorMessage = "版本落后";
                break;

            case FA_SN_ERROR:
                errorMessage = "SN码不存在";
                break;

            case FA_SN_BIND_ERROR:
                errorMessage = "SN码已经被绑定";
                break;

            case FA_NO_DATA_ERROR:
                errorMessage = "未查询到信息";
                break;

            case FA_RIGHT_ERROR:
                errorMessage = "无权限";
                break;

            case FA_API_ERROR:
                errorMessage = "接口不存在";
                break;

//            case POWER_ERROR:
//                errorMessage = "解绑定人为孩子的唯一管理员";
//                break;
            case UNBIND_DELETE_ERROR:
                errorMessage = "解绑孩子仍然绑定手表,请先解绑孩子的手表后,再解绑定孩子";
                break;
            default:

                errorMessage = "未知错误";

                LogUtil.e("err", "没有对应的code!!!!!");

                break;

        }
//        ctx = null;
        return errorMessage;

    }

    /*关注人的权限*/
    public final static int POWER_TEACHER = 10; //老师
    public final static int POWER_ADMIN = 1; //管理员
    public final static int POWER_PARENT = 2;//亲人
    public final static int POWER_FRIEND = 3;//朋友
    public final static int POWER_DEL = 0;//删除权限

}
